﻿using Systems.SaveSystem;
using UnityEngine;
using UnityEngine.UI;

public class TestUI : MonoBehaviour
{
    private PlayerLevelComp levelComp;
    private PlayerAttributeComp attributeComp;

    public Button testUpLevelBt;
    public Button testSaveGameBt;
    public Button printAttribute;

    private void Awake()
    {
        levelComp = FindFirstObjectByType<PlayerLevelComp>();
        attributeComp = levelComp.transform.GetComponent<PlayerAttributeComp>();
    }

    void Start()
    {
        testUpLevelBt.onClick.AddListener(() =>
        {
            // 测试 经验加减
            levelComp.AddExperience(100);
        });
        testSaveGameBt.onClick.AddListener(() =>
        {
            // 保存游戏
            GuidSaveManager.Instance.SaveScene();
            DynamicSaveManager.Instance.SaveScene();
        });
        printAttribute.onClick.AddListener(() =>
        {
            // 打印属性
            Debug.Log("生命:" + attributeComp.GetAttributeValue(AttributeType.MaxHP));
            Debug.Log("攻击:" + attributeComp.GetAttributeValue(AttributeType.Attack));
            Debug.Log("防御:" + attributeComp.GetAttributeValue(AttributeType.Defense));
            Debug.Log("速度:" + attributeComp.GetAttributeValue(AttributeType.Speed));
            Debug.Log("暴击率:" + attributeComp.GetAttributeValue(AttributeType.CritRate));
            Debug.Log("暴击伤害:" + attributeComp.GetAttributeValue(AttributeType.CritDamage));
            Debug.Log("伤害加成:" + attributeComp.GetAttributeValue(AttributeType.DamageBonus));
            Debug.Log("治疗加成:" + attributeComp.GetAttributeValue(AttributeType.HealingBonus));
            Debug.Log("伤害减免:" + attributeComp.GetAttributeValue(AttributeType.DamageReduction));
            Debug.Log("等级:" + levelComp.level);
            Debug.Log("经验:" + levelComp.experience);
        });
    }
}